package com.dts.servlet;

import jakarta.servlet.ServletContext;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet(name = "servlet1", urlPatterns = "/servlet1")
public class Servlet1 extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String company = "isoftstone";
        ServletContext context = this.getServletConfig().getServletContext();// 获得ServletContext对象
        context.setAttribute("company", company); // 将data存储到ServletContext对象中
    }
}
